package com.seth.myapplication.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by Seth on 2017/11/9.
 */

public class StringHelper {


    static boolean flag = false;
    static String regex = "";

    public static boolean check(String str, String regex) {
        try {
            Pattern pattern = Pattern.compile(regex);
            Matcher matcher = pattern.matcher(str);
            flag = matcher.matches();
        } catch (Exception e) {
            flag = false;
        }
        return flag;
    }

    public static boolean checkCellphone(String cellphone) {
        String regex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0-1]|[5-9]))\\d{8}$";
        return check(cellphone, regex);
    }
}
